<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>添加快递员</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input name="uname" class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input name="phone" class="input" placeholder="请输入手机号码" onblur="checkPhone()"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input name="ID_Card" class="input" placeholder="请输入身份证号码" onblur="checkId_card()"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input name="password" class="input" placeholder="请输入密码" onblur="checkPassword()"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="form">立即提交</span> <span class="btn">重置</span> </td>
					</tr>
				</table>


			</div>
		</div>
	</body>
	<script src="../../assets/layui.all.js"></script>
	<script src="/qrcode/jquery2.1.4.js"></script>
	<script src="/layer/layer.js"></script>
	<script>
		var form = layui.form
				,layer = layui.layer;
	</script>
	<script>


		// 验证密码 6-18位 只包含数字和字母
		function checkPassword(){
			var pattern = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z\\W]{6,18}$/;
			var password = document.getElementsByName("password")[0].value;
			if (password.match(pattern) == null){
				alert("请输入6-18位只包含数字和字母的密码");
			}else
				console.log("password="+password);
		}

		// \d{17}[\d|x]|\d{15}

		// 验证身份证号码
		function checkId_card(){
			var pattern = /^\d{17}[\d|x]|\d{15}$/;
			var id_card = document.getElementsByName("ID_Card")[0].value;
			if (id_card.match(pattern) == null){
				alert("请输入正确的身份证号");
			}else
				console.log("id_card="+id_card);

		}

		// 验证手机号
		// 0?(13|14|15|18)[0-9]{9}
		function checkPhone(){
			var pattern = /^0?(13|14|15|18)[0-9]{9}$/;
			var phone = document.getElementsByName("phone")[0].value;
			if (phone.match(pattern) == null){
				alert("请输入以13，14，15，18开头的11位的手机号");
			}else
				console.log("phone="+phone);

		}
	</script>
	<script>
		$(function(){
			$("#form").click(function(){
				var windowId = layer.load();
				var name = $("input:eq(0)").val();
				var phone = $("input:eq(1)").val();
				var ID_Card = $("input:eq(2)").val();
				var password = $("input:eq(3)").val();
				$.post("/courier/insert.do",{
					name:name,
					phone:phone,
					ID_Card:ID_Card,
					password:password
				},function(data){
					layer.close(windowId);
					layer.msg(data.result);

				});

				return false;
			});


		});
	</script>
</html>
